/**
 * 
 */
package cn.edu.nju.ws.sview.wyge.relations.adataset;

import java.sql.Connection;
import java.sql.PreparedStatement;

import cn.edu.nju.ws.sview.cache.UserNameIDCache;
import cn.edu.nju.ws.sview.database.DBConnectionFactory;

/**
 * @author Weiyi Ge (geweiyi@gmail.com) 2012-7-24
 * 
 */
@Deprecated
public class VisitDataset {
	public static void visit(String userName, String ds_type, int ds_id,
			String lang) {
		try {
			Connection con = DBConnectionFactory.getConnection();
			PreparedStatement insertps = con
					.prepareStatement("insert into ds_user_visit "
							+ "(user_id, ds_type, ds_id, lang) values (?, ?, ?, ?) on duplicate"
							+ " key update times_total = times_total+1");

			int user_id = 0;
			if (userName != null){
				user_id = UserNameIDCache.getInstance().getUserID(userName);
			}
//			System.out.println("dsid:"+ds_id);
			insertps.setInt(1, user_id);
			insertps.setString(2, ds_type);
			insertps.setInt(3, ds_id);
			insertps.setString(4, lang);
			insertps.executeUpdate();

			insertps.close();
			con.close();
		} catch (Throwable e) {
			e.printStackTrace();
		}
	}
}
